package dao

import (
	"fmt"

	xgorm "gitee.com/douhun/easy-ngo/app/plugins/plugin_xgrom"
	"gitee.com/douhun/easy-ngo/examples/quickstart/pkg/do"
)

func GetUser(name string) *do.UserInfo {
	cli := xgorm.GetDBClientByKey("demo01")
	if cli == nil {
		fmt.Print("failed.")
		return nil
	}
	var user = new(do.UserInfo)
	err := cli.Where("name", name).Find(user).Error
	if err != nil {
		return nil
	}
	return user
}

func UserPassport(name string) string {
	cli := xgorm.GetDBClient()
	if cli == nil {
		return ""
	}
	var user = new(do.UserInfo)
	err := cli.Where("name", name).Find(user).Error
	if err != nil {
		return ""
	}
	return user.Passport
}
